home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
tpb4_src.zip
/
FILEMNU1.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-09-13
|
13KB
|
433 lines
{ TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen
Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault
Last modified :: 7-3-88 8:22 pm
}
{$R-} {Range checking off}
{$B-} {Boolean complete evaluation off}
{$S-} {Stack checking off}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
Unit FileMnu1;
Interface
Uses
TPCrt, Dos, Globals, Core1,
Core2, TPSTRING, TPDOS, Dirs;
procedure ArcLbr;
procedure toggle_st_switch;
procedure file_area_change(req : DosFileName);
procedure directory(disp : Boolean);
{=========================================================================}
Implementation
procedure ArcLbr;
var
Req : DosFileName;
This : FilePtr;
Extension : string[4];
OK : Boolean;
begin
if in_library then
begin
SetSect(SetName); { Close file }
{$I-}
Close(libr_file) {$I+} ;
OK := (IoResult = 0);
SetSect(HomName);
while LibBase <> nil do { Clean out old list }
begin
This := LibBase;
LibBase := LibBase^.next; { Go to next on chain }
Dispose(This) { Reclaim space }
end;
in_library := False;
WriteLn(Com, 'Library ', LibReq, ' closed.')
end
else if in_arc then
begin
SetSect(SetName); { Close file }
{$I-}
Close(arc_file);
{$I+}
OK := (IoResult = 0);
SetSect(HomName);
while ArcBase <> nil do { Clean out old list }
begin
This := ArcBase;
ArcBase := ArcBase^.next; { Go to next on chain }
Dispose(This) { Reclaim space }
end;
in_arc := False;
WriteLn(Com, 'Arc File ', ArcReq, ' closed.')
end
else
begin
Req := prompt('Arc/Library name', 12, 'ES');
Delete(Req, 1, Pos(':', Req));
if (Pos('.', Req) = 0) and (Req <> ' ') then
begin
SetSect(SetName);
Extension := '';
if ExistFile(Req+'.ARC') then
Extension := '.ARC'
else if ExistFile(Req+'.LBR') then
Extension := '.LBR'
else if ExistFile(Req+'.ARK') then
Extension := '.ARK';
if Extension <> '' then
Req := Req+Extension;
SetSect(HomName)
end;
if Req = ' ' then
begin
end
else if JustExtension(Req) = 'LBR' then
begin
LibReq := Req;
LibReadDir(LibEntries, LibSpace, LibBase);
if not in_library then
WriteLn(Com, 'Cannot open ', LibReq, '.')
end
else if (JustExtension(Req) = 'ARC') or (JustExtension(Req) = 'ARK') then
begin
ArcReq := Req;
ArcReadDir(ArcEntries, ArcSpace, ArcBase);
if not in_arc then
WriteLn(Com, 'Cannot open ', ArcReq, '.')
end
else
WriteLn(Com, 'Couldn''t locate any ARC, ARK, or LBR files by that name.');
end;
end;
procedure toggle_st_switch;
{ Toggle file size display }
begin
WriteLn(Com);
st_switch := not st_switch;
Write(Com, 'File sizes will be shown in ');
if st_switch then
WriteLn(Com, 'bytes, where "k" is 1024.')
else
WriteLn(Com, 'minutes and seconds of transfer time.')
end;
procedure file_area_change(Req : DosFileName);
{ View and set up file area for use }
const
col_width = 16;
var
drive : Str3;
col_count,
col_limit,
conf_num,
line_count,
section_count : Integer;
This : SectPtr;
pr : StrPr;
SameSect, OK : Boolean;
procedure display_long;
begin
This := SectBase;
WriteLn(Com);
line_count := 2;
section_count := 1;
while (not brk) and (This <> nil) do
begin
conf_num := This^.SectConf;
if (user_rec.access >= This^.SectAccs) or (test_bit(user_rec.conf_flags,
conf_num)) then
begin
WriteLn(Com, hi, yellow, intstr(section_count, 2), ' ',
pad(This^.SectName, 13), low, green, This^.SectDesc);
Inc(section_count);
end;
This := This^.next;
if user_rec.lines <> 99 then
begin
Inc(line_count);
if line_count mod user_rec.lines = 0 then
pause;
end;
end;
Write(Com, hi, cyan);
WriteLn(Com);
end;
procedure display_short;
var
wrap_on_next : Boolean;
pad_count : Byte;
begin
WriteLn(Com);
abort := False;
col_count := 0;
This := SectBase;
Write(Com, hi, yellow);
section_count := 1;
while (not brk) and (This <> nil) do
begin
conf_num := This^.SectConf;
if (user_rec.access >= This^.SectAccs) or (test_bit(user_rec.
conf_flags, conf_num)) then
begin
Inc(col_count);
wrap_on_next := (0 = col_count mod col_limit);
if wrap_on_next then
pad_count := 1
else
pad_count := 13;
Write(Com, yellow, intstr(section_count, 2), cyan, ' ',
pad(This^.SectName, pad_count));
if wrap_on_next then
WriteLn(Com);
Inc(section_count);
end;
This := This^.next
end;
Write(Com, cyan);
if 0 <> col_count mod col_limit then
WriteLn(Com);
WriteLn(Com);
end;
begin {file area change}
SameSect := False;
section_count := 1;
col_limit := max(1, user_rec.columns div col_width);
if Req = '' then
begin
pr := white+'Enter Area Name or #'+cyan;
WriteLn(Com);
Req := prompt(pr, 12, 'ES?M');
if Req = ' ' then
begin
Req := SectReq; {default to current setting}
SameSect := True;
end
else
SameSect := False;
end;
while (not new_dir) and (Online) and (not SameSect) do
begin
This := SectBase;
if (Req = '?') or (Req = '/') then
begin
WriteLn(Com);
WriteLn(Com, 'Available file areas:');
display_short;
repeat
Req := prompt(pr+' ["?" for Descriptions]', 12, 'ES?');
if (Req = '?') or (Req = '/') then
display_long;
until (Req <> '?') and (Req <> '/');
if Req = ' ' then
Req := SectReq;
end
else if Req <> '' then
begin
FindSect(Req, drive, OK);
if OK then
begin
SectReq := Req;
SetDrv := drive;
if (Req = 'SYSTEM') and (HomName[1] = drive[1]) then
SetName := HomName
else
begin
SetName := drive;
if (Length(HomName) > 3) and (drive = HomDrv) then
begin
SetName := SetName+Copy(HomName, 4, Length(HomName));
SetName := SetName+'\';
end;
if Pos(':', Req) = 2 then
SetName := SetName+Copy(Req, 3, Length(Req))
else
SetName := SetName+Req;
end;
ReadDir(DirEntries, DirSpace, DirBase);
end
else
begin
WriteLn(Com, '"', Req, '" not found. Available file areas:');
display_short;
repeat
Req := prompt(pr+' ["?" for Descriptions]', 12, 'ES?');
if (Req = '?') or (Req = '/') then
display_long;
until (Req <> '?') and (Req <> '/');
if Req = ' ' then
Req := SectReq;
end
end
end
end;
procedure directory(disp : Boolean);
{ Display file area or library directory }
const
col_width = 19;
var
i, j, k,
entries, Rows,
mm, ss,
col_limit,
line_count : Integer;
size : LongInt;
This : FilePtr;
nodes : array[1..4] of FilePtr;
st : Str10;
fn : DosFileName;
show_dir : Boolean;
begin
show_dir := disp;
abort := False;
col_limit := max(1, user_rec.columns div col_width);
if show_dir then
WriteLn(Com, hi);
new_dir := False;
if in_library then
begin
This := LibBase;
show_dir := True;
entries := LibEntries;
if show_dir then
if entries = 0 then
WriteLn(Com, ' Library: ', LibReq, ' is empty.')
else
WriteLn(Com, yellow, ' Library: ', LibReq, ' Files: ', entries, ' Space used: ',
LibSpace, 'k')
end
else if in_arc then
begin
This := ArcBase;
show_dir := True;
entries := ArcEntries;
if show_dir then
if entries = 0 then
WriteLn(Com, ' Arc File: ', ArcReq, ' is empty.')
else
WriteLn(Com, yellow, ' Arc File: ', ArcReq, ' Files: ', entries, ' Space used: ',
ArcSpace, 'k')
end
else
begin
This := DirBase;
entries := DirEntries;
if show_dir then
if entries = 0 then
WriteLn(Com, ' File area: ', SectReq, ' is empty.')
else
Write(Com, yellow, ' File area: ', SectReq, ' Files: ', entries, ' Space used: ',
DirSpace, 'k');
if (user_rec.access >= 250) and show_dir then
WriteLn(Com, ' Free: ', free_space, 'k')
else if show_dir then
WriteLn(Com);
end;
line_count := 2;
if show_dir then
Write(Com, cyan);
if (entries > 0) and show_dir then
begin
Rows := entries div col_limit;
if 0 <> entries mod col_limit then
Inc(Rows);
nodes[1] := This;
for i := 2 to col_limit do
begin
for J := 1 to Rows do
This := This^.next;
nodes[i] := This
end;
i := 1;
while (not brk) and (i <= Rows) do
begin
for J := 1 to col_limit do
begin
This := nodes[J];
if (i+Rows*Pred(J)) <= entries then
begin
if st_switch then
begin
size := This^.fsize shr 3;
if (This^.fsize mod 8) <> 0 then
Inc(size);
st := intstr(size, 4)+'k '
end
else
begin
send_time(This^.fsize, mm, ss);
st := intstr(mm, 3)+':'+intstr(ss, 2);
for K := 3 to Length(st) do
if st[K] = ' ' then
st[K] := '0'
end;
fn := This^.fname;
if test_bit(This^.attrib, 1) then
begin
fn[9] := '*'; { Indicate $SYS file }
Write(Com, low, green, fn, st, hi, cyan)
end
else
Write(Com, fn, st);
if J < col_limit then
Write(Com, dir_fence, ' ')
else
WriteLn(Com)
end
else
WriteLn(Com);
nodes[J] := nodes[J]^.next { Go to next on list }
end;
if user_rec.lines <> 99 then
begin
Inc(line_count);
if line_count mod user_rec.lines = 0 then
pause
end;
Inc(i)
end
end;
if (J <> col_limit) and show_dir then
WriteLn(Com)
end;
end. { of FILEMNU1.PAS }